<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
<head>
<title>用户管理</title>
</head>
<body>
	<div id="layout-main-right-header">
		<p>用户管理</p>
	</div>
	<div id="layout-main-right-content">
		<div>
		    <form:form method="POST" action="list.html" id="searchForm">
				<input type="hidden" name="pageNo" id="pageNo" value="${page.pageNo}"/>
				<input type="hidden" name="orderBy" id="orderBy" value="${page.orderBy}"/>
				<input type="hidden" name="order" id="order" value="${page.order}"/>			
				<div id="divFilter" title="查询条件" style="margin:5px; border:0px solid red;">
						<label for="filters[0].value">名称:</label>
						<input type="hidden" name="filters[0].name" value="LIKES_loginName"></input>
						<input type="textbox" name="filters[0].value" class="text ui-widget-content ui-corner-all" value="${page.filters[0].value}"/>
				</div>	
				<div style="margin-left:5px;">
					<input type="button" id="search" value="查询" class="button_selector" />
					<input type="button" id="add" value="新增" class="button_selector" />
					<input type="button" id="update" value="更新" class="button_selector" />
					<input type="button" id="delete" value="删除" class="button_selector" />
				</div>	
				<div>
					<table class="tablesorter" id="mainTable" cellspacing="1">
						<thead>
							<tr>
								<th style="width:50px;">选择</th>
								<th class="header">ID</th>
								<th class="header">登录名</th>
								<th class="header">姓名</th>
								<th class="header">邮件</th>
								<th class="header">创建时间</th>
								<th class="header">更新时间</th>
							</tr>
						</thead>
						<tbody>
							<c:set var="i" scope="page" value="0" />
							<c:forEach var="user" items="${page.result}">
								<tr class=<c:if test="${(i % 2) == 0}">"odd"</c:if>
									<c:if test="${(i % 2) == 1}">"even"</c:if>>
									<td><input type="radio" name="radioSelected" value="${user.id}" class="text ui-widget-content ui-corner-all"></input></td>
									<td>${user.id}</td>
									<td>${user.loginName}</td>
									<td>${user.name}</td>
									<td>${user.email}</td>
									<td><fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss"
									value="${user.createTime}" /></td>
									<td><fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss"
									value="${user.updateTime}" /></td>
								</tr>
								<c:set var="i" scope="page" value="${i+1}" />
							</c:forEach>
						</tbody>
					</table>
				</div>
				<div style="float:right;margin-right:20px;">
					共${page.totalCount}条
					<c:if test="${page.paginated}">
						&nbsp;&nbsp;第${page.pageNo}页/共${page.totalPages}页
						<a href="javascript:jumpPage(1)">首页</a>
						<c:if test="${page.hasPre}"><a href="javascript:jumpPage(${page.prePage})">上一页</a></c:if>
						<c:if test="${page.hasNext}"><a href="javascript:jumpPage(${page.nextPage})">下一页</a></c:if>
						<a href="javascript:jumpPage(${page.totalPages})">末页</a>
					</c:if>
				</div>				
			</form:form>				
		</div>
	</div>
	<div class="clear"></div>	

	<script type="text/javascript">
		jQuery(function($) {
			$("#add").click(function() {
				addUser();
			})

			$("#update").click(function() {
				updateUser();
			})

			$("#delete").click(function() {
				deleteUser();
			})
			
			$("#search").click(function() {
				searchUser();
			})
						
			
			function searchUser() {
				doSearch();
			}
			
			<c:if test="${not empty page.result}">
			$("#mainTable").tablesorter({
				sortList : [ [ 1, 0 ] ],
				widgets : [ 'zebra' ]
			});// sort on the first column and third column, order asc 
			</c:if>

			function deleteUser() {
				var id =$('input[name=radioSelected]:checked').val();
				if ( id == undefined || id == '' ) {
					alert('请选择一条记录!');
					return;
				}
				return;
			}
			
			function updateUser() {
				var id =$('input[name=radioSelected]:checked').val();
				if ( id == undefined || id == '' ) {
					alert('请选择一条记录!');
					return;
				}
				location.href="./edit/"+ id +'.html';
				return;
			}			

			function addUser() {
				location.href="./add.html";
				return true;
			}

			$(".button_selector").button();
	
		});
	</script>
</body>
</html>